package com.aos.erp.schools.rest.student;

import com.aos.erp.common.bean.ResultEntity;
import com.aos.erp.schools.cutils.router.Rest;
import com.aos.erp.schools.model.student.StudentReportresult;
import com.aos.erp.schools.model.student.StudentWarning;
import com.aos.erp.schools.model.student.ro.reportresult.AddReportresultRo;
import com.aos.erp.schools.service.student.StudentReportresultService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Auther: chb
 * @Date: 2018/11/1 19:22
 * @Description:    学员成绩表
 */
@RestController
@RequestMapping(Rest.StudentReportresult.ROOT)
@Api(tags = {"学员成绩信息"})
public class StudentReportresultController {

    @Autowired
    private StudentReportresultService studentReportresultService;


    @PostMapping(Rest.StudentReportresult.add)
    @ApiOperation(value = "学员成绩信息添加")
    public ResultEntity addStudentPicture(AddReportresultRo ro){

        try {
            StudentReportresult pram=new StudentReportresult();
            BeanUtils.copyProperties(ro,pram);
            studentReportresultService.saveBean(pram);
            return ResultEntity.success("学员成绩信息添加成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return ResultEntity.failed("学员成绩信息添加失败!");
        }

    }


    @PostMapping(Rest.StudentReportresult.update)
    @ApiOperation(value = "学员成绩信息修改")
    public ResultEntity updateStudentPicture(StudentReportresult sr){

           int row=studentReportresultService.updateBean(sr);
           if(row>0)
           {
               return ResultEntity.success("学员成绩修改成功!");
           }
           return ResultEntity.failed("学员成绩修改失败!");
    }

    @PostMapping(Rest.StudentReportresult.getByStudentId)
    @ApiOperation(value = "学员成绩信息查询")
    @ApiImplicitParam(name = "studentId",value = "学员Id",required = true,dataType ="Long",paramType ="query" )
    public ResultEntity getByStudentId(Long studentId){
        try {
           // List<StudentWarning> listSw=studentReportresultService
            return ResultEntity.success();
        } catch (Exception e) {
            e.printStackTrace();
            return ResultEntity.failed("学员成绩查询失败!");
        }
    }



}
